Google News
logo
JavaScript - Interview Questions
Explain the unshift() method ?
This method is functional at the starting of the array, unlike the push(). It adds the desired number of elements to the top of an array. For example :
 
var name = [ "free" ];
name.unshift( "time" );
name.unshift( "learning", "FTL" );
console.log(name);
 
The output is shown below:
 
[" free "," time ", " learning ", " FTL "]
Advertisement